<%@ Language=VBScript %>
<%
	Session("FormName")=""
%>
<!--#include file="..\CheckSession.inc"-->
<!--#include file=..\getFormName.inc-->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.Document">

<%
	Set ClsFun=server.CreateObject("Vinalines.ClsFunction")
	Dim IDFlow
	IDFlow=request("IDFlow")
	Nguoitao=request("Nguoitao")
	Filename=Request("Filename")
	UName=Request("Username")
	Hanxuly=Request("Hanxuly")
	if cdate(hanxuly)<date() then
		bExpire=true
	else
		bExpire=fasle
	end if
	Yeucau=Request("Yeucau")
	MaCB=Request("MaCB")
	Tentep=Request("Tentep")
	Maflow=Request("Maflow")
	bMaRoot=Request("bMaRoot")
	bComm=Request("bComm")
	bok=false

	'QuangND 7_1_03
	sSQL = "Select trangthaixl from Flownode where maworkflownode='"& ToGiaiMa(Maflow) &"'"	
	Set RecStatus=server.CreateObject("ADODB.Recordset")
	RecStatus.CursorType = 3
	RecStatus.CacheSize = 5
	RecStatus.Open sSQL, Conn
	If (not RecStatus.Eof) and (not RecStatus.BOF) then
		mStatus=RecStatus("trangthaixl")
	Else
		mStatus="1"
	End if
	RecStatus.Close
	Set RecStatus= Nothing
	'7_1_03

	if yeucau="2" then
		bComm = "xulyok"
		bok=true
	end if
	bDatao=request("bDatao") 'Kiem tra xem nut hientai da tao flow ch&#432;a n&#7871;u 	ch&#432;a th&#236; cho ph&#233;p t&#7841;o conkh&#244;ng th&#236; cho s&#7917;a
	'***********Sau khi nguoi dung xu ly thi thay doi trang thai nhan**********************	
	If bComm = "xulyok" Then
			Dim bMaFlowgiaima, bLen, bItem
	        bMaFlowgiaima = ToGiaiMa(maflow)
	        'sSQL = "Update Flownode set ykien='" & ToModiString(Request("TxtYkien")) & "' where MaWorkflownode like '" & bMaFlowgiaima & "'"
	        'Conn.Execute sSQL
	        status = Request("Status")
	        if bok then
		    status="2"
	        end if
	        yeucau = Request("yeucau")
	        If yeucau = "2" Then
	            sSQL = "Update Flownode Set trangthaixl=2 where  Maworkflownode like '" & bMaFlowgiaima & "' and nguoixuly like '" & Session("bMaCB") & "'"
	            Conn.Execute sSQL
	            'Tim Con
	            bLen = ItemLast(bMaFlowgiaima) * 2 - 1
	            bItem = Left(bMaFlowgiaima, bLen + 4) & "%%"
	                  For i = ItemLast(bItem) + 2 To (Len(bMaFlowgiaima) - 1) / 2
	                    bItem = bItem & "00"
	                  Next
	            sSQL = "Update Flownode Set trangthaixl=0,thuhoi=0 where trangthaixl<>1 and trangthaixl<>2 and Maworkflownode<>'" & bMaFlowgiaima & "' and Maworkflownode like '" & bItem & "' "
	            Conn.Execute sSQL
	        Else
	            If status = "2" Then
	                  sSQL = "Update Flownode Set trangthaixl=2 where Maworkflownode like '" & bMaFlowgiaima & "' and nguoixuly like '" & Session("bMaCB") & "'"
	                  Conn.Execute sSQL
	                  bLen = ItemLast(bMaFlowgiaima) * 2 - 1
	                  bItem = Left(bMaFlowgiaima, bLen + 4) & "%%"
	                  For i = ItemLast(bItem) + 2 To (Len(bMaFlowgiaima) - 1) / 2
	                    bItem = bItem & "00"
	                  Next
	                  sSQL = "Update Flownode Set trangthaixl=0,thuhoi=0 where  trangthaixl=-1 and Maworkflownode<>'" & bMaFlowgiaima & "' and Maworkflownode like '" & bItem & "' "
	                  Conn.Execute sSQL
	            Else
	                If status = "1" Then
	                    sSQL = "Update Flownode Set trangthaixl=1,thuhoi=0 where Maworkflownode like '" & bMaFlowgiaima & "' and nguoixuly like '" & Session("bMaCB") & "'"
	                    Conn.Execute sSQL
	                Else
	                    'Set Rec = Server.CreateObject("ADODB.Recordset")
	                    'Dim RecTam As New ADODB.Recordset
	                    Set RecTam=server.CreateObject("ADODB.Recordset")
	                    RecTam.CursorType = 3
	                    RecTam.CacheSize = 5
	                    sSQL = "Select * from Flownode where Maworkflow like '" & IDFlow & "' and nguoixuly like '" & Session("bMaCB") & "'"
	                    RecTam.Open sSQL, Conn
	                    Do While Not RecTam.EOF
	                        If ((RecTam("Trangthaixl") = 0) Or (RecTam("Trangthaixl") = Null)) Then
	                            If Rec("yeucauxl") = "1" Then
	                                sSQL = "Update Flownode Set trangthaixl=1,thuhoi=0 where Maworkflownode like '" & Rec("Maworkflownode") & "'" ' and nguoixuly like '"& Session("bMaCB") &"'"
	                            Else
	                                sSQL = "Update Flownode Set trangthaixl=2 where Maworkflownode like '" & Rec("Maworkflownode") & "'" ' and nguoixuly like '"& Session("bMaCB") &"'"
	                            End If
	                            Conn.Execute sSQL
	                        End If
	                        RecTam.MoveNext
	                    Loop
	                    RecTam.Close
	                    Set RecTam = Nothing
	                End If
	                  bLen = ItemLast(bMaFlowgiaima) * 2 - 1
	                  bItem = Left(bMaFlowgiaima, bLen + 4) & "%%"
	                  sSQL = "Update Flownode Set trangthaixl=-1,thuhoi=0 where Maworkflownode<>'" & bMaFlowgiaima & "' and Maworkflownode like '" & bItem & "' "
	                  Conn.Execute sSQL	                  
	            End If
	        End If
	        Filename = Request("Filename")
	        Nguoitao = Request("Nguoitao")
		        
	    End If
 %>
 <%
	'**************Lay gia tri sua nut con de nguoi dung co the sua
	if bDatao then
		sSQL="Select * from workflow where Nodecha like '"& clsfun.Giaima(maflow) &"'"
		Set RecLay=server.CreateObject("ADODB.Recordset")
		RecLay.CursorType=3
		RecLay.CacheSize=5
		RecLay.Open sSQL,Conn
		if RecLay.RecordCount then
			IDFlowcon=RecLay("maworkflow")
			Session("VanBan")=Session("VanBan") & IDFlowcon & "-" 
		else
			IDFlowcon=""
		end if
		RecLay.Close
		Set RecLay=nothing
	end if
	'***************Kiem tra neu thuoc nhom con thi nguoi xu ly khong duoc phep mo nut con
	sSQL="Select * from workflow where maworkflow like '"& IDFlow &"'"	
	Set RecKTCon=server.CreateObject("ADODB.Recordset")
	RecKTCon.CursorType=3
	RecKTCon.CacheSize=5
	RecKTCon.Open sSQL,Conn
	if RecKTCon.RecordCount then
		if isnull(RecKTCon("Nodecha")) then
			bChopheptao=true			
		else
			bChopheptao=false
			Nodecha=RecKTCon("Nodecha")
			NodeIDFlow=left(Nodecha,5)
		end if
	end if
	RecKTCon.Close
	Set RecKTCon=nothing
 %>
 <%
	'****************Kiem tra neu toan bo nhanh con da xu ly xong thi cho node goc cua nhanh chinh doi mau
	if (not bChopheptao) And (bComm = "xulyok") then
		sSQL="Select * from flownode where maworkflow like '"& IDFlow &"'"
		Set RecKTXL=server.CreateObject("ADODB.Recordset")
		RecKTXL.Open sSQL,Conn
		bOK=true
		Do while not RecKTXL.EOF
			if RecKTXL("Trangthaixl")<>2 then
				bOK=false
				exit do
			end if
			RecKTXL.MoveNext
		Loop
		RecKTXL.Close
		Set RecKTXL=nothing
		if bOK then 'Da xu ly xong nhanh con
			Trangthaixl="2"
		else
			Trangthaixl="1"
		end if
		
	'***************Doi trang thai sau khi xuly nhanh con
		'Dim bMaFlowgiaima, bLen, bItem
		bMaFlowgiaima = Nodecha
		status = Trangthaixl
		If status = "2" Then
	                  sSQL = "Update Flownode Set trangthaixl=2 where Maworkflownode like '" & bMaFlowgiaima & "'"
	                  Conn.Execute sSQL
	                  bLen = ItemLast(bMaFlowgiaima) * 2 - 1
	                  bItem = Left(bMaFlowgiaima, bLen + 4) & "%%"
	                  For i = ItemLast(bItem) + 2 To (Len(bMaFlowgiaima) - 1) / 2
	                    bItem = bItem & "00"
	                  Next
	                  sSQL = "Update Flownode Set trangthaixl=0 where  trangthaixl=-1 and Maworkflownode<>'" & bMaFlowgiaima & "' and Maworkflownode like '" & bItem & "' "
	                  Conn.Execute sSQL	                  
	                  Call Xuly(bItem,bMaFlowgiaima,true)
		Else
			If status = "1" Then
				sSQL = "Update Flownode Set trangthaixl=1 where Maworkflownode like '" & bMaFlowgiaima & "'"
				Conn.Execute sSQL
			Else
				Set RecTam=server.CreateObject("ADODB.Recordset")
				RecTam.CursorType = 3
				RecTam.CacheSize = 5
				sSQL = "Select * from Flownode where Maworkflow like '" & NodeIDFlow & "' and nguoixuly like '" & bMaRoot & "'"
				RecTam.Open sSQL, Conn
				Do While Not RecTam.EOF
					If ((RecTam("Trangthaixl") = 0) Or (RecTam("Trangthaixl") = Null)) Then
						If Rec("yeucauxl") = "1" Then
						    sSQL = "Update Flownode Set trangthaixl=1 where Maworkflownode like '" & Rec("Maworkflownode") & "'" ' and nguoixuly like '"& Session("bMaCB") &"'"
						Else
						    sSQL = "Update Flownode Set trangthaixl=2 where Maworkflownode like '" & Rec("Maworkflownode") & "'" ' and nguoixuly like '"& Session("bMaCB") &"'"
						End If
						Conn.Execute sSQL
					End If
					RecTam.MoveNext
				Loop
				RecTam.Close
				Set RecTam = Nothing
			End If
			bLen = ItemLast(bMaFlowgiaima) * 2 - 1
			bItem = Left(bMaFlowgiaima, bLen + 4) & "%%"
			sSQL = "Update Flownode Set trangthaixl=-1 where Maworkflownode<>'" & bMaFlowgiaima & "' and Maworkflownode like '" & bItem & "' "
			Conn.Execute sSQL
			Call Xuly(bItem,bMaFlowgiaima,false)
		End If
	End if
	
 %>
 <!--#include file="..\jvfunction.inc"-->
<SCRIPT ID=clientEventHandlersJS LANGUAGE=javascript>
<!--
function CmdBack_onclick() {
	
	frmxl.target="right";
	<%if request("bComm")="flow" then%>
		act="xulyflow.asp?bComm=xulyok&Status=1&bMaRoot="+"<%=bMaRoot%>"+"&IDFlow="+"<%=IDFlow%>"+"&Nguoitao="+"<%=Nguoitao%>"+"&Filename="+"<%=Filename%>";
	<%else%>
		act="xulyflow.asp?bComm=xulyok&Status=1&bMaRoot="+"<%=bMaRoot%>"+"&yeucau="+"<%=yeucau%>"+"&IDFlow="+"<%=IDFlow%>"+"&Nguoitao="+"<%=Nguoitao%>"+"&Filename="+"<%=Filename%>"+"&Maflow="+"<%=Maflow%>";
	<%end if%>
	frmxl.action=act;
	frmxl.submit();
}
/*function CmdNotOK_onclick() {
	frmxl.target="right";
	frmxl.action="xulyflow.asp?bMaRoot="+"<%=bMaRoot%>"+"&bComm=xulyok&Status=1&yeucau="+"<%=yeucau%>"+"&IDFlow="+"<%=IDFlow%>"+"&Nguoitao="+"<%=Nguoitao%>"+"&Filename="+"<%=Filename%>"+"&Maflow="+"<%=Maflow%>";
	frmxl.submit();
}
function CmdOK_onclick() {	
		frmxl.target="right";
		frmxl.action="xulyflow.asp?bMaRoot="+"<%=bMaRoot%>"+"&bComm=xulyok&yeucau="+"<%=yeucau%>"+"&Status=2&IDFlow="+"<%=IDFlow%>"+"&Nguoitao="+"<%=Nguoitao%>"+"&Filename="+"<%=Filename%>"+"&Maflow="+"<%=Maflow%>";
		frmxl.submit();
}*/
function CmdChuyenDi_onclick() {
	<%if bExpire then%>
		alert("Bạn đã quá hạn xử lý");
		return false;
	<%end if%>
	window.frmxl.target="right";
	window.frmxl.action="../xuly/frmVTDi.asp?bDangky=ok&ChuyenVTDi=ok&bComm=add&IDFlow="+"<%=IDFlow%>"+"&maflow="+"<%=maflow%>";
	window.frmxl.submit();
}
function CmdChuyenQD_onclick() {
	<%if bExpire then%>
		alert("Bạn đã quá hạn xử lý");
		return false;
	<%end if%>
	window.frmxl.target="right";
	window.frmxl.action="../xuly/frmVTQuyetDinh.asp?bDangky=ok&ChuyenVTQD=ok&bComm=add&IDFlow="+"<%=IDFlow%>"+"&maflow="+"<%=maflow%>";
	window.frmxl.submit();
}
function  CmdChuyennoibo_onclick(){
	<%if bExpire then%>
		alert("Bạn đã quá hạn xử lý");
		return false;
	<%end if%>
	window.frmxl.target="right";
	window.frmxl.action="../xuly/frmVTNoibo.asp?bDangky=ok&ChuyenVTNoibo=ok&bComm=add&IDFlow="+"<%=IDFlow%>";
	window.frmxl.submit();	
}
function CmdXuly_onclick() {
	//bg thphuc 20-02-03
	<%if not bExpire or Session("IsAdmin") or Session("ClsFun").LayGiaTriQuyen(Session("Permision"),"F39",1)="1" then%>
	//ed thphuc 20-02-03
		//bg thphuc 21-01-03 xu ly y kien
		frmxl.action="xulyyeucau/frmedit.asp?IDFlow="+"<%=IDFlow%>"+"&bMaRoot="+"<%=bMaRoot%>"+"&Nguoitao="+"<%=Nguoitao%>"+"&Yeucau="+"<%=Yeucau%>"+"&Filename="+"<%=Filename%>"+"&UName="+"<%=UName%>"+"&Hanxuly="+"<%=Hanxuly%>"+"&MaCB="+"<%=MaCB%>"+"&Tentep="+"<%=Tentep%>"+"&Maflow="+"<%=Maflow%>"+"&bDatao="+"<%=bDatao%>";	
		frmxl.target="right";
		//ed thphuc 21-01-03 xu ly y kien
		frmxl.submit();
	<%else%>
		alert("Bạn đã quá hạn xử lý");
		return false;
	<%end if%>
}

function CmdChuyentiep_onclick() {
	//alert("CHUYEN TIEP");
//	alert('<%=bMaRoot%>');	
//	alert('<%=IDFlow%>');		
//	alert('<%=ToGiaiMa(Maflow)%>');	//maflownode
//	alert('<%=MaxChild(ToGiaiMa(Maflow))%>');	//id

	frmxl.action="flow.asp?bMaRoot="+"<%=bMaRoot%>"+"&bComm=add&IdFlow="+"<%=IDFlow%>"+"&id="+"<%=ToMahoa(Left(MaxChild(ToGiaiMa(Maflow)) + "000000000000000000",23))%>"+"&Trangthai="+"<%=mStatus%>"+"&Maflownode="+"<%=Maflow%>"+"&Nguoitao="+"<%=Session("bMaCB")%>";	
	frmxl.target="right";
	frmxl.submit();
}

function CmdCreateflow_onclick(bPhanhoi) {
	<%if bExpire then%>
		alert("Bạn đã quá hạn xử lý");
		return false;
	<%end if%>
	<%if bDatao then %>		act="flow.asp?bTheodoi=ok&IDFlow="+"<%=IDFlowcon%>"+"&Nguoitao="+"<%=Session("bMaCB")%>"+"&bMaRoot="+"<%=Session("bMaCB")%>";
		frmxl.action=act;
		frmxl.target="right";
		frmxl.submit();
	<%else%>	
		if(!confirm("Bạn có thực sự tạo thêm luồng xử lý không ?")){
			return false;
		}	
		if(bPhanhoi){
			act="CreateWorkflow.asp?bPhanhoi=OK&bComm=nguoncon&bMaflownode="+"<%=Maflow%>";
		}
		else{
			act="CreateWorkflow.asp?bComm=nguoncon&bMaflownode="+"<%=Maflow%>";
		}
		frmxl.action=act;
		frmxl.target="right";
		frmxl.submit();
	<%end if%>	
	
}

//-->
</SCRIPT>
<title>Hệ Quản Trị Văn Thư</title>
</head>
<LINK href="../styles/styles.css" type=text/css rel=STYLESHEET>
<body style="font-family:Arial" topmargin=0 leftmargin=0 bgcolor=#F8F9D9>
<form name=frmxl method=post>
<input type=hidden name=Maflow value="<%=maflow%>">
<input type=hidden name=Yeucau value="<%=Yeucau%>">
<input type=hidden name=bDatao value='<%=bDatao%>'>
<table border="0" bgcolor= #F8F9D9 style="border-left-style: solid; border-left-color: #ffffff; border-right-style: solid; border-right-color: #808080; border-top-style: solid; border-bottom-style: solid; border-bottom-color: #808080" width="100%" cellPadding="0" cellspacing="0">

  <tr>
    <td width="15%">Ng&#432;&#7901;i y&#234;u c&#7847;u</td>
    <td width="35%">
	<font face="Arial" color="blue">
	<%	'sSQL="Select macanbo,Hovaten from canbo Where macanbo Like '"& bMaRoot &"'"
		sSQL="Select macanbo,Hovaten from canbo Where macanbo in (select idnguoitao from flownode where maworkflownode='"& ToGiaiMa(Maflow) &"')"	
		Set RecCanbo=server.CreateObject("ADODB.Recordset")
		RecCanbo.CursorType=3
		RecCanbo.CacheSize=5
		RecCanbo.Open sSQL,Conn
		if RecCanbo.RecordCount then
			%><B><i><%=Reccanbo("hovaten")%></i></B><%
		end if
		RecCanbo.Close
		Set RecCanbo=nothing
	%>
    </font></td>
    <%if yeucau="1" then%>
		<%if Request("bDatao") then%>
			<td width="50%" colspan=4>
		     	<input type="button" value="Đã ủy quyền"  name="CmdXuly" language="javascript" style="WIDTH: 100%; FONT-FAMILY: times new roman" onclick="return CmdXuly_onclick()" disabled>
			</td>		      
		 <%else%>
			<td width="25%" colspan=2>
				<input type="button" value="Xử lý" name="CmdXuly" language="javascript" style="WIDTH: 100%; FONT-FAMILY: times new roman" onclick="return CmdXuly_onclick()">
			</td>
			<td width="25%" colspan=2>
				<% if Session("ClsFun").LayGiaTriQuyen(Session("Permision"),"F37",1)="1" or Session("IsAdmin") then %>
					<input type="button" value="Chuyển tiếp xử lý" name="CmdChuyentiep" language="javascript" style="WIDTH: 100%; FONT-FAMILY: times new roman" onclick="return CmdChuyentiep_onclick()">
				<% else %>
					<input type="button" value="Chuyển tiếp xử lý" disabled name="CmdChuyentiep" language="javascript" style="WIDTH: 100%; FONT-FAMILY: times new roman" onclick="return CmdChuyentiep_onclick()">
				<% end if %>
			</td>			
		 <%end if%>
     <%else%>
	     <td width="25%" colspan=2>
			<input type="button" value="Xử lý" name="CmdXuly" language="javascript" style="WIDTH: 100%; FONT-FAMILY: times new roman;" onclick="return CmdXuly_onclick()" disabled>
	     </td>
		<td width="25%" colspan=2>
				<% if Session("ClsFun").LayGiaTriQuyen(Session("Permision"),"F37",1)="1" or Session("IsAdmin") then %>
					<input type="button" value="Chuyển tiếp xử lý" name="CmdChuyentiep" language="javascript" style="WIDTH: 100%; FONT-FAMILY: times new roman" onclick="return CmdChuyentiep_onclick()">
				<% else %>
					<input type="button" value="Chuyển tiếp xử lý" disabled name="CmdChuyentiep" language="javascript" style="WIDTH: 100%; FONT-FAMILY: times new roman" onclick="return CmdChuyentiep_onclick()">
				<% end if %>
		</td>	     
     <%end if%>
  </tr>
  <tr>
    <td width="15%">Th&#7901;i h&#7841;n x&#7917; l&#253;</td>
    <td width="35%"><font face="Arial" color="blue"><B><i><%=ClsFun.FormatDate(hanxuly)%></i></B></font></td>
    <%if Request("bDatao") then%>
    <td width="50%" colspan="4">
      <input language="javascript" style="WIDTH: 100%; FONT-FAMILY: times new roman" onclick="return CmdCreateflow_onclick(1)" type="button" value="Theo dõi ủy quyền" name="CmdCreateflow"></td>
      <%else%>
		<%if bChopheptao then%>
			<%if Session("ClsFun").LayGiaTriQuyen(Session("Permision"),"F32",1)="1" or Session("IsAdmin") 	then%>
				<td width="25%" colspan="2">
				<input  type="button" value="Uỷ quyền có phản hồi" name="CmdCreateflow" language="javascript" style="WIDTH: 100%; FONT-FAMILY: times new roman" onclick="return CmdCreateflow_onclick(1)"></td>
			<%else%>
				<td width="25%" colspan="2">
				<input language="javascript" style="WIDTH: 100%; FONT-FAMILY: times new roman" onclick="return CmdCreateflow_onclick(1)" type="button" value="Uỷ quyền có phản hồi" disabled name="CmdCreateflow"></td>
			<%end if%>
			<%if Session("ClsFun").LayGiaTriQuyen(Session("Permision"),"F32",2)="1" or Session("IsAdmin") 	then%>
				<td width="25%" colspan="2">
				<input type="button" value="Uỷ quyền không phản hồi" name="CmdCreateflow" language="javascript" style="WIDTH: 100%; FONT-FAMILY: times new roman" onclick="return CmdCreateflow_onclick(0)"></td>
			<%else%>
				<td width="25%" colspan="2">
				<input language="javascript" style="WIDTH: 100%; FONT-FAMILY: times new roman" onclick="return CmdCreateflow_onclick(0)" type="button" value="Uỷ quyền không phản hồi" disabled 	name="CmdCreateflow"></td>
			<%end if%>
		<%else%>
		<td width="25%" colspan="2">
		<input language="javascript" style="WIDTH: 100%; FONT-FAMILY: times new roman" onclick="return CmdCreateflow_onclick(1)" type="button" value="Uỷ quyền có phản hồi" disabled name="CmdCreateflow"></td>
		<td width="25%" colspan="2">
		<input language="javascript" style="WIDTH: 100%; FONT-FAMILY: times new roman" onclick="return CmdCreateflow_onclick(0)" type="button" value="Uỷ quyền không phản hồi" disabled name="CmdCreateflow"></td>
		<%end if%>
      <%end if%>
  </tr>
  <tr>
    <td width="15%">Yêu cầu xử lý</td>
    <td width="35%" rowspan="2">
    <%
		  sSQL="Select * from flownode where maworkflownode like '"& ClsFun.Giaima(Maflow) &"'"		  		  
		  Set RecNode=server.CreateObject("ADODB.Recordset")
		  RecNode.CursorType=3
		  RecNode.CacheSize=5
		  RecNode.Open sSQL,Conn
	if RecNode.RecordCount then%>
    <textarea style="WIDTH: 100%; COLOR: blue; FONT-FAMILY: Arial;  BACKGROUND-COLOR: #f8f9d9" name="ghichu" readOnly wrap="hard" cols="39" rows="2"><%=RecNode("Ghichu")%></textarea>
    <%end if%>
    </td>

    <%if Session("ClsFun").LayGiaTriQuyen(Session("Permision"),"F20",4)="1" or Session("IsAdmin") then%>
		<td width="14%">
		<input language="javascript" style="WIDTH: 100%; FONT-FAMILY: times new roman" onclick="return CmdChuyenDi_onclick()" type="button" value="Chuyển CV đi" name="CmdChuyenDi"></td>
      <%else%>
		<td width="14%">
		 <input language="javascript" style="WIDTH: 100%; FONT-FAMILY: times new roman" onclick="return CmdChuyenDi_onclick()" type="button" disabled value="Chuyển CV đi" name="CmdChuyenDi"></td>
	<%end if%>
	<%if Session("ClsFun").LayGiaTriQuyen(Session("Permision"),"F21",4)="1" or Session("IsAdmin") then%>
		<td width="22%" colspan="2">
		<input language="javascript" style="WIDTH: 100%; FONT-FAMILY:  times new roman" onclick="return CmdChuyenQD_onclick()" type="button" value="Chuyển QĐ" name="CmdQD"></td>
      <%else%>
		<td width="22%" colspan="2">
	      <input language="javascript" disabled style="WIDTH: 100%; FONT-FAMILY:  times new roman" onclick="return CmdChuyenQD_onclick()" type="button" value="Chuyển QĐ" name="CmdQD"></td>
      <%end if%>
      <%if Session("ClsFun").LayGiaTriQuyen(Session("Permision"),"F23",4)="1" or Session("IsAdmin") then%>
    <td width="14%">
      <input language="javascript" style="WIDTH: 100%; FONT-FAMILY: times new roman" onclick="return CmdChuyennoibo_onclick()" type="button" value="Chuyển CV nội bộ" name="CmdChuyennoibo"></td>
    <%else%>
    <td width="14%">
      <input language="javascript" disabled style="WIDTH: 100%; FONT-FAMILY: times new roman" onclick="return CmdChuyennoibo_onclick()" type="button" value="Chuyển CV nội bộ" name="CmdChuyennoibo"></td>
      <%end if%>
  </tr>
  <tr>
    <td width="15%">&nbsp;</td>
    <td width="50%" colspan="4">
    <input language="javascript" style="WIDTH: 100%; FONT-FAMILY: Times New Roman" onclick="return CmdBack_onclick()" type="button" value="Quay l&#7841;i" name="CmdBack"></td>
  </tr>
</table>
</form>
</body>

</html>
<script language=VBScript runat=server>
 Function ChildFirst(Item1, Item2)
        Dim It1, It2
        It1 = Item1
        It2 = Item2
        ChildFirst = False
        If ItemLast(It2) > ItemLast(It1) Then
            ChildFirst = True
        End If
End Function
    'Em thu
Function ChildSecond(Item1, Item2)
        Dim It1, It2
        It1 = Item1
        It2 = Item2
        ChildSecond = False
        If ItemLast(It1) = ItemLast(It2) Then
            ChildSecond = True
        End If
End Function
    'Vi tri bit so sanh
Function ItemLast(Item)
        Dim i
        Dim It
        Dim vt
        Dim j, Temp
        It = Item
        It = Right(It, Len(It) - 4)
        j = 1
        For i = 2 To Len(It)
            If i < Len(It) Then
                Temp = Mid(It, i, 1)
                i = i + 1
                Temp = Temp & Mid(It, i, 1)
                j = j + 1
                If Temp = "00" Then
                    ItemLast = j - 1
                    Exit For
                Else
                    If i = Len(It) Then
                        ItemLast = j
                    End If
                End If
            End If
        Next
    End Function
Function Repl(Item, pos)
        Dim It
        Dim vt
        Dim bL
        It = Item
        bL = Left(It, 4)
        It = Right(It, Len(It) - 4)
        c = Len(It)
        It = Left(It, pos * 2 - 3)
        Repl = bL & It
    End Function
Function NumberChild(Item)
        Dim It
        Dim i, Last
        Dim Temp
        It = Item
        Temp = Repl(It, ItemLast(It) + 1)
        Last = ItemLast(It)
        c = ItemLast(Temp)
        Temp = Left(Temp, Len(Temp) - 2)
        Temp = Temp & "%%"
        Dim vt
        vt = Col / 2 - 1
        For i = c To vt
            Temp = Temp & "00"
        Next
        sSQL = "Select Maworkflownode From Flownode where Maworkflownode Like '" & Temp & "' Order by Maworkflownode"
        'Set RecMax = Server.CreateObject("Adodb.Recordset")
        'Dim RecMax As New ADODB.Recordset
        Set RecMax=server.CreateObject("ADODB.Recordset")
        RecMax.CursorType = 3
        RecMax.CacheSize = 5
        RecMax.Open sSQL, Conn
        If Last = 2 Then
            NumberChild = RecMax.RecordCount
        Else
            NumberChild = RecMax.RecordCount - 1
        End If
        RecMax.Close
        Set RecMax = Nothing
    End Function

Function MaxChild(Item)
        Dim It
        Dim i
        Dim Temp1
        Dim vt, bCount
        It = Item
        Temp1 = Repl(It, ItemLast(It) + 1)
        Temp1 = Temp1 & "%%"
        c = ItemLast(Temp1) + 1
        vt = Col / 2
        For i = c To vt
            Temp1 = Temp1 & "00"
        Next
        sSQL = "Select Maworkflownode From Flownode where Maworkflownode Like '" & Temp1 & "' Order by Maworkflownode"
        'Set RecMax = Server.CreateObject("Adodb.Recordset")
        'Dim RecMax As New ADODB.Recordset
        Set RecMax=server.CreateObject("ADODB.Recordset")
        RecMax.CursorType = 3
        RecMax.CacheSize = 5
        RecMax.Open sSQL, Conn
        RecMax.MoveLast
        Temp1 = Repl(RecMax("Maworkflownode"), ItemLast(RecMax("Maworkflownode")) + 1)
        Dim cuoi
        If RecMax.RecordCount = 1 Then
            If ItemLast(It) <> 1 Then
                Temp1 = Temp1 & "01"
            Else
                dau = Left(Temp1, Len(Temp1) - 2)
                cuoi = Right(Temp1, 2)
                If Left(cuoi, 1) <> "0" Then
                    cuoi = CInt(cuoi) + 1
                Else
                    cuoi = CStr(CInt(Right(cuoi, 1)) + 1)
                    If Len(cuoi) = 1 Then
                        cuoi = "0" & cuoi
                    End If
                End If
                Temp1 = dau + CStr(cuoi)
            End If
        Else
            dau = Left(Temp1, Len(Temp1) - 2)
            cuoi = Right(Temp1, 2)
            If Left(cuoi, 1) <> "0" Then
                cuoi = CInt(cuoi) + 1
            Else
                   cuoi = CStr(CInt(Right(cuoi, 1)) + 1)
                   If Len(cuoi) = 1 Then
                        cuoi = "0" & cuoi
                    End If
            End If
            'cuoi = CInt(cuoi) + 1
            Temp1 = dau + CStr(cuoi)
        End If
        bCount = ItemLast(It) + 2
        For i = bCount To vt
            Temp1 = Temp1 & "00"
        Next
        MaxChild = Temp1
        RecMax.Close
        Set RecMax = Nothing
End Function

Function ToMahoa(msText)
        Dim nC
        Dim lI
        Dim lJ
        Dim nK
        Dim lA
        Dim sB
        lA = Len(msText)
        sB = Space(lA + (lA + 2) \ 3)
        For lI = 1 To lA
            nC = Asc(Mid(msText, lI, 1))
            lJ = lJ + 1
            sB = Mid(sB, 1, lJ - 1) & Chr((nC And 63) + 59) & Mid(sB, lJ + 1, Len(sB) - lJ)
            Select Case lI Mod 3
            Case 1
                nK = nK Or ((nC \ 64) * 16)
            Case 2
                nK = nK Or ((nC \ 64) * 4)
            Case 0
                nK = nK Or (nC \ 64)
                lJ = lJ + 1
                sB = Mid(sB, 1, lJ - 1) & Chr(nK + 59) & Mid(sB, lJ + 1, Len(sB) - lJ)
                nK = 0
            End Select
        Next
        If lA Mod 3 Then
            lJ = lJ + 1
            sB = Mid(sB, 1, lJ - 1) & Chr(nK + 59) & Mid(sB, lJ + 1, Len(sB) - lJ)
        End If
        ToMahoa = sB
    End Function
    '******Giai ma xau************************
Function ToGiaiMa(msText)
        Dim nC
        Dim nD
        Dim nE
        Dim lA
        Dim lB
        Dim lI
        Dim lJ
        Dim lK
        Dim sB
        lA = Len(msText)
        lB = lA - 1 - (lA - 1) \ 4
        sB = Space(lB)
        For lI = 1 To lB
            lJ = lJ + 1
            nC = Asc(Mid(msText, lJ, 1)) - 59
            Select Case lI Mod 3
            Case 1
                lK = lK + 4
                If lK > lA Then lK = lA
                nE = Asc(Mid(msText, lK, 1)) - 59
                nD = ((nE \ 16) And 3) * 64
            Case 2
                nD = ((nE \ 4) And 3) * 64
            Case 0
                nD = (nE And 3) * 64
                lJ = lJ + 1
            End Select
            sB = Mid(sB, 1, lI - 1) & Chr(nC Or nD) & Mid(sB, lI + 1, Len(sB) - lI)
        Next
        ToGiaiMa = sB
    End Function

Function ToSaveDate(vDate)
        Dim bvitri1
        Dim bvitri2
        Dim bMonth, bDay, bYear
       vDate = Trim(CStr(vDate))
       bvitri1 = InStr(1, vDate, "/")
       bMonth = Left(vDate, bvitri1 - 1)
       bvitri2 = InStr(bvitri1 + 1, vDate, "/")
       Dim Temp
       Temp = Right(vDate, Len(vDate) - bvitri1)
       bDay = Left(Temp, bvitri2 - bvitri1 - 1)
       bYear = Right(vDate, Len(vDate) - bvitri2)
       ToSaveDate = bDay + "/" + bMonth + "/" + bYear
    End Function
    ' H&#224;m &#273;&#7883;nh d&#7841;ng l&#7841;i ng&#224;y M/D/Y-> D/M/Y
Function ToFormatDate(vDate)
        Dim vM, vD, vY
       If Not IsNull(vDate) Then
            vM = Right("0" & Month(vDate), 2)
            vD = Right("0" & Day(vDate), 2)
            vY = Right("19" & Year(vDate), 4)
            ToFormatDate = vD & "/" & vM & "/" & vY
       End If
    End Function
Function ToModiString(mess_s)
        Dim message
        message = Replace("" & mess_s, "'", "''")
        ToModiString = message
End Function
'Dung de kich hoat dong con khi cha no duoc kich hoat hoacmo di
Function Xulycon(bMa,bActive)
	if bActive then 'Khi nut cha duoc phep xu ly
		sSQL="Select * from flownode where maworkflow like '"& bMa &"' order by maworkflownode"
		Set RecXLC=server.CreateObject("ADODB.Recordset")
		RecXLC.CursorType=3
		RecXLC.CacheSize=5
		RecXLC.Open sSQL,Conn
		Do While not RecXLC.EOF
			bCond=Itemlast(RecXLC("maworkflownode"))
			if bCond=2 then
				sSQL="Update flownode set trangthaixl=0 where trangthaixl=-1 and maworkflownode like '"& RecXLC("maworkflownode") &"'"
				Conn.Execute sSQL
			end if
			RecXLC.MoveNext
		Loop
		RecXLC.Close
		set RecXLC=nothing
	else 'Khi nut cha khong duoc phep xu ly
		sSQL="Update flownode set trangthaixl=-1 where maworkflow like '"& bMa &"'"
		Conn.Execute sSQL
	end if	
End Function
'Xuly cac nut con sau khi nut con cua mot nhanh khac xu ly
Function Xuly(bMaflownode,bCurrent,bActive)
	sSQL="Select * from flownode where maworkflownode like '"& bMaflownode &"' and Maworkflownode<>'" & bCurrent & "'"
	Set RecTimcon=server.CreateObject("ADODB.Recordset")
	RecTimcon.CursorType=3
	RecTimcon.CacheSize=5
	RecTimcon.Open sSQL,Conn
	Do while not RecTimcon.EOF
		if not isnull(RecTimcon("maworkflowcon")) then	
			Call Xulycon(RecTimcon("maworkflowcon"),bActive)
			RecTimcon.MoveNext
		end if
		RecTimcon.MoveNext
	Loop
	RecTimcon.Close
	Set RecTimcon=nothing
End Function
</script>